package b4.config
{
	import flash.geom.Point;
	
	public class LayerItemConfig
	{
		public static const NAMES:Array = ["空地", "墙", "传送点", "门", "迷宫物品", "宝箱", "怪物"];
		//消失
		public static const STATUS_CLEAR:int = 0;
		//正常
		public static const STATUS_NORMAL:int = 1;
		//锁定
		public static const STATUS_LOCK:int = 2;
		
		//空地
		public static const TYPE_EMPTY:int = 0;
		//墙
		public static const TYPE_WALL:int = 1;
		//传送点
		public static const TYPE_PORT:int = 2;
		//门
		public static const TYPE_GATE:int = 3;
		//迷宫物品
		public static const TYPE_MAZE_OBJECT:int = 4;
		//宝箱
		public static const TYPE_TREASURE_BOX:int = 5;
		//怪物
		public static const TYPE_CREATURE:int = 6;
		
		//索引
		public var index:int;
		//类型
		public var type:int;
		//占位
		public var occPoints:Object;
		
		public function LayerItemConfig(itemStrs:Array = null)
		{
			occPoints = new Object();
			if (itemStrs != null)
			{
				type = parseInt(itemStrs[0]);
				var occup:Array = itemStrs[1].split(" ");
				for (var i:int = 0; i < (occup.length - 1) / 2; i++)
				{
					var posX:int = parseInt(occup[2 * i]);
					var posY:int = parseInt(occup[2 * i + 1]);
					occPoints[posX + " " + posY] = this;
				}
			}
		}

		public function serializeExport():String
		{
			var serialStr:String = type + ","; 
			for (var posStr:String in occPoints)
			{
				if (occPoints[posStr] != null)
				{
					serialStr += posStr + " ";
				}
			} 
			return serialStr;
		}
	}
}